package com.course.chapter6;


import java.math.BigDecimal;
import java.util.Date;
import java.util.concurrent.LinkedBlockingDeque;

public class BLockQueueDemo {

    public static void main(String[] args) {
        Double buyerItNowPrice =2.99;
        Double prictDouble = 0.3;
        new BigDecimal(1.0);
        new BigDecimal("1.0");
        Double newPrice = BigDecimal.valueOf(buyerItNowPrice - prictDouble).setScale(2,BigDecimal.ROUND_UP).doubleValue();

        LinkedBlockingDeque<String> lbd=new LinkedBlockingDeque<>(10);
        Thread thread = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                for (int i1 = 0; i1 < 10; i1++) {
                    String system = new String(i + ":" + i1);
                    try {
                        lbd.put(system);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("cllient:"+system+(new Date()));
                }
            }
        });
        thread.start();
        for (int i = 0; i < 10; i++) {
            for (int i1 = 0; i1 < 10; i1++) {
                String take = null;
                try {
                    take = lbd.take();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("main take:"+take+":size "+lbd.size());
            }
        }

    }
}
